package com.wholesmart.common.utils;

import org.springframework.web.context.request.RequestAttributes;

/**
 * 用于操作Session的工具类
 * 
 * @author dyw
 * @date 2019年12月3日
 */
public class HttpSessionUtils {
	/** 用于将用户名存储到session中的KEY */
	public static String CURRENT_USER_KEY = "current_user_key";

	public void setAttribute(RequestAttributes request, String name, Object value) {
		request.setAttribute(name, value, RequestAttributes.SCOPE_SESSION);
	}

	public Object getAttribute(RequestAttributes request, String name) {
		return request.getAttribute(name, RequestAttributes.SCOPE_SESSION);
	}

	public void removeAttribute(RequestAttributes request, String name) {
		request.removeAttribute(name, RequestAttributes.SCOPE_SESSION);
	}
}
